package cn.qihang.ssm.service.impl;

import cn.qihang.ssm.mapper.TravellerMapper;
import cn.qihang.ssm.pojo.Traveller;
import cn.qihang.ssm.service.TravellerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: qihang
 * @Date: 2022/11/2 17:39
 * @Desc:
 */
@Service
public class TravellerServiceImpl implements TravellerService {

    @Autowired
    private TravellerMapper travellerMapper;

    /**
     * 查询所有游客
     * @return
     */
    @Override
    public List<Traveller> findAll() {

        return this.travellerMapper.findAll();
    }


    /**
     * 游客详情
     * @param id
     * @return
     */
    @Override
    public Traveller findById(Integer id) {
        return this.travellerMapper.findById(id);
    }

    /**
     * 新增游客
     * @param traveller
     */
    @Override
    public void save(Traveller traveller) {
        this.travellerMapper.save(traveller);
    }


    /**
     * 修改游客信息
     * @param traveller
     * @return
     */
    @Override
    public void edit(Traveller traveller) {
        this.travellerMapper.edit(traveller);
    }

    /**
     * 指定删除游客
     * @param id
     */
    @Override
    public void deleteById(Integer id) {
        //删除order_traveller表中与游客关联的订单号
        this.travellerMapper.delete_order_travellerById(id);
        //删除traveller表中的游客信息
        this.travellerMapper.deleteById(id);
    }
}
